package plus.stmt;

import plus.B;
import plus.Gripe;
import plus.exp.Exp;
import plus.run.Emit;

public class P_Eval extends Statement {
	final Exp exp;
	final boolean isVoid;
	final int lineNr;

	public P_Eval(Exp exp, boolean isVoid, int lineNr) {
		this.exp = exp;
		this.isVoid = isVoid;
		this.lineNr = lineNr;
	}

	@Override
	public void threadScope() {
		Gripe.context = this;
		Gripe.lineNr = lineNr;
		exp.threadScope();
		Gripe.context = this;
		if (isVoid) exp.unify_with(B._void);
	}
	
	@Override public String toString() {
		return "Procedure Call: "+exp;
	}

	@Override
	public
	void compile() {
		exp.compilePush();
		if (!isVoid) Emit.pop();
	}
}
